home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / apps / math / ols.zoo / epp2tex.naw (.txt) < prev    next >
LaTeX Document  |  1993-04-16  |  3KB  |  100 lines

  1. BEGIN {
  2.     serr = "/dev/tty";    # standard error
  3.     bs = "\\";        # used anytime I want a backslash
  4.     mc = "multicolumn";    # short form
  5.     bsmc = bs mc;    # short form
  6.     fnum = 4; 
  7.     if (putfree==1) fnum++; if (putt==1) fnum++;
  8.         # how many fields/line is the generated table going to have?
  9.     # Header:
  10.     print bs "documentstyle[11pt]{article}";
  11.     print bs "begin{document}"; print "";
  12.     print bs "begin{table}[h]";
  13.     print bs "centering";
  14.     # Need to generate argument for \begin{tabular}
  15.     if (putfree==1) {
  16.         if (putt==1) llstring = "llcrrr";
  17.         else llstring = "llcrr";
  18.     else {
  19.         if (putt==1) llstring = "llrrr";
  20.         else llstring = "llrr";
  21.     print bs "begin{tabular}{|" llstring "|} " bs "hline";
  22.     # Headings at top of table:
  23.     print bsmc "{" fnum "} {|l|} {} " bs bs;
  24.     print "  " bsmc "{1} {|l} {} & {Parameter}";
  25.     if (putfree==1) print "& " bsmc "{1} {c}  {Free?}";
  26.     print "& " bsmc "{1} {c}  {Estimate}";
  27.     if (putt==0)    # no t-stat
  28.         print "& " bsmc "{1} {c|}  {Standard Error}" bs bs;
  29.     else {
  30.         print "& " bsmc "{1} {c}  {Standard Error}";
  31.         print "& " bsmc "{1} {c|}  {t-statistic} " bs bs;
  32.     # horizantal line and a blank line:
  33.     print bsmc "{" fnum "}{|l|} {} " bs bs " " bs "hline";
  34.     print bsmc "{" fnum "}{|l|} {} " bs bs;
  35. # action on all lines:
  36. {taken = 0}    # this line has not yet been parsed.
  37. # Look for captions
  38. ($1 ~ /[Cc][Aa]/) {
  39.     # collect together text of caption:
  40.     s = ""; for (i=2; i<=NF; i++) s = s $i " ";
  41.     # file it away into variable "captionstring"
  42.     captionstring = s;
  43.     # it's used in END
  44.     taken = 1;
  45.     # say I have parsed this line.
  46. # blank lines:
  47. ($1 ~ /[bB][lL]/) {
  48.     if (NF != 1) {
  49.         print "Error on line " NR ": only 1 field allowed." > serr;
  50.         goch=1; exit 1;
  51.     else
  52.         print bsmc "{" fnum "}{|l|} {} " bs bs;
  53.     taken = 1;
  54. # parameter estimates
  55. ($1 ~ /[eE][sS]/) {
  56.     label = $2;
  57.     # parse "free":
  58.     free=-1;    # error code is -1
  59.     if (($3 ~ /[yY][eE][sS]/) || ($3 ~ /^[tT]/)) free=1;
  60.     if (($3 ~ /[nN][oO]/) || ($3 ~ /^[fF]/)) free = 0;
  61.     if (free == -1) {
  62.         print "Error in FREE parameter on line " NR > serr;
  63.         goch=1; exit 1;
  64.     # Check number of fields on the line is ok.
  65.     expectfields = ((free == 0) ? 4 : 5);
  66.     if (NF != expectfields) {
  67.         print "Expect " expectfields " fields on line " NR > serr;
  68.         goch = 1; exit 1
  69.     # Grab estimate, serror, compute t if needed.
  70.     theta = $4; 
  71.     se=""; if (free==1) se=$5;
  72.     t=""; if ((free==1) && (putt==1)) t = (1.0*theta)/(1.0*se);
  73.     # Start creating the line to be emitted:
  74.     s = "{} & {" label "}";
  75.     if (putfree==1) s = s " & {" ((free==1) ? "Yes":"No") "}";
  76.     s = s " & {" theta "} & {" se "}";
  77.     if (putt==1) s = s " & {" t "} " bs bs;
  78.     else s = s bs bs;
  79.     print s;
  80.     taken = 1;
  81. # comment lines:
  82. ($1 ~ /[cC][oO]/) {
  83.     s = ""; for (i=2; i<=NF; i++) s = s $i " ";
  84.     print bsmc "{" fnum "}{|l|} {{" bs "sf " s "}}" bs bs;
  85.     taken=1
  86. # if taken is still zero for this line, it's garbage.
  87. (taken == 0) {
  88.     print "Could not parse line " NR > serr;
  89.     goch = 1; exit 1;
  90. # Now close down things nicely and quit.
  91. END {
  92.     if (goch == 1) {
  93.         print "Fatal error... exiting" > serr
  94.         exit 1;
  95.     print bs mc "{" fnum "}{|l|} {}" bs bs bs "hline";
  96.     print bs "end{tabular}"
  97.     print bs "caption{" captionstring "}";
  98.     print bs "end{table}";
  99.     print bs "end{document}";
  100.